package com.example.ViewPagerSum.util;

import com.example.ViewPagerSum.domain.MMDetailPthoto;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * ============================================================
 * author：     王景
 * <p/>
 * time：       2015/9/20  22:32.
 * <p/>
 * email:     wjontheway@163.com
 * <p/>
 * description：
 * <p/>
 * ============================================================
 */
public class ParseMmDetailJson {

    public MMDetailPthoto  getMmPhotoList(String json){
        MMDetailPthoto mp=null;
        try {
            JSONObject object=new JSONObject(json);
            mp=new MMDetailPthoto();
            int count = object.getInt("count");
            int size = object.getInt("size");
            String title = object.getString("title");

            mp.setCount(count);
            mp.setSize(size);
            mp.setTitle(title);

            JSONArray phlist = object.getJSONArray("list");
            for (int i=0;i<phlist.length();i++){
                JSONObject itemObject = phlist.getJSONObject(i);
                mp.parseJson(itemObject);

            }
        } catch (JSONException e) {
            e.printStackTrace();
            return  mp;
        }
        return  mp;
    }
}
